import tools from "../../../tools"
import hierParentModel from './hierParentModel'

export default class chainModel extends hierParentModel {
  constructor(hierProperties) {
    super(hierProperties, chainModel)
  }
  // 保存前, 格式化content数据
  formatContent() {
    if (this.hierProperties.content && this.hierProperties.content.length) {
      let prevItem = {}
      this.hierProperties.content = this.hierProperties.content.map(item => {
        let res = {
          ...item,
          prev: prevItem.nodeId ? [prevItem.nodeId] : []
        }
        prevItem = item
        return res;
      })
    }
  }
  static tpl() {
    return {
      type: 'chain',
      content: [
        // item
      ]
    }
  }
  static itemTpl() {
    return {
      nodeId: tools.uuid(),
      prev: [], //前驱节点
      nodeType: "leaf",  //['root', 'list', 'dictionary', 'leaf']
      name: "新增节点",
      properties: [],
      statusProperties: [],
      link: {
        //指针格式
        // type: "",
        // className: "",
      },
    }
  }
}

